package com.ysncms.ext;

import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

public class GetClient {
	
	// http://localhost:8080/RESTfulExample/json/product/get
	public static void main(String[] args) {
 
	  try {
		  String urlParameters = "agra.wal.vs@gmail.com";
  
		URL url = new URL("http://buyer.yoursuppliernetwork.com/tnvrs/userservice/login/forgotpwd/");
		HttpURLConnection conn = (HttpURLConnection) url.openConnection();
		//conn.setRequestMethod("GET");
		//conn.setRequestProperty("Accept", "application/json");
		conn.setDoOutput(true);
		conn.setDoInput(true);

		conn.setRequestMethod("POST"); 
		conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); 
		conn.setRequestProperty("charset", "utf-8");
		conn.setRequestProperty("Content-Length", "" + Integer.toString(urlParameters.getBytes().length));
		conn.setUseCaches (false);

 
		DataOutputStream wr = new DataOutputStream(conn.getOutputStream ());
		wr.writeBytes(urlParameters);
		wr.flush();
		wr.close();
		//conn.disconnect();

 
		BufferedReader br = new BufferedReader(new InputStreamReader(
			(conn.getInputStream())));
 
		String output;
		System.out.println("Output from Server .... \n");
		while ((output = br.readLine()) != null) {
			System.out.println(output);
		}
 
		conn.disconnect();
 
	  } catch (MalformedURLException e) {
 
		e.printStackTrace();
 
	  } catch (IOException e) {
 
		e.printStackTrace();
 
	  }
 
	}
}
